package at.socialconference.inter.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

public class User implements Serializable, Updatetable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8303101325665560046L;
	
	// Low Level: min infos

	public static final int LEVEL_LOW = 0;
	public static final int LEVEL_MEDIUM = 1;
	public static final int LEVEL_HIGH = 2;

	private Integer id;

	private String firstname;

	private String lastname;

	private String gender;

	private String phone;

	private String title;

	private String webpage;

	private String dblp;

	private String city;

	private String country;

	private String address;

	private String tw_access_token;

	private String tw_access_secret;

	private ArrayList<User> contacts = new ArrayList<User>();
	
	private Integer securityLevel;

	public User(Integer id, String firstname, String lastname, String gender, String phone, String title, String webpage, String dblp,
			String city, String country, String address, String zip, String mail, ArrayList<User> contacts, String tw_access_token,
			String tw_access_secret) {
		super();
		this.id = id;
		this.firstname = firstname;
		this.lastname = lastname;
		this.gender = gender;
		this.phone = phone;
		this.title = title;
		this.webpage = webpage;
		this.dblp = dblp;
		this.city = city;
		this.country = country;
		this.address = address;
		this.zip = zip;
		this.mail = mail;
		this.tw_access_token = tw_access_token;
		this.tw_access_secret = tw_access_secret;

		this.contacts = contacts == null ? new ArrayList<User>() : contacts;
	}

	public User() {
		// TODO Auto-generated constructor stub
	}

	private String zip;

	private String mail;

	private Set<String> fieldOfInterests = new HashSet<String>();

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	
	public String getFullName() {
		String tmp = "";
		if(this.getTitle()!=null&&this.getTitle().length()>0)
			tmp += this.getTitle();
		tmp+=this.getFirstname()+" "+this.getLastname();
		return tmp;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getWebpage() {
		if (webpage != null) {
			if (webpage.startsWith("http://"))
				return webpage;
			else
				return "http://" + webpage;
		} else
			return null;
	}

	public void setWebpage(String webpage) {
		this.webpage = webpage;
	}

	public String getDblp() {
		if (dblp != null) {
			if (dblp.startsWith("http://"))
				return dblp;
			else
				return "http://" + dblp;
		} else {
			return null;
		}
	}

	public void setDblp(String dblp) {
		this.dblp = dblp;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getZip() {
		return zip;
	}

	public void setZip(String zip) {
		this.zip = zip;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public Set<String> getFieldOfInterests() {
		return fieldOfInterests;
	}

	public void setFieldOfInterests(Set<String> fieldOfInterests) {
		this.fieldOfInterests = fieldOfInterests;
	}

	public void addTopic(String fieldOfInterests) {
		this.fieldOfInterests.add(fieldOfInterests);
	}

	public void addContact(User user) {
		contacts.add(user);
	}

	public ArrayList<User> getContacts() {
		return contacts;
	}

	public void setContacts(ArrayList<User> contacts) {
		this.contacts = contacts;

	}

	public String getTw_access_token() {
		return tw_access_token;
	}

	public void setTw_access_token(String tw_access_token) {
		this.tw_access_token = tw_access_token;
	}

	public String getTw_access_secret() {
		return tw_access_secret;
	}

	public void setTw_access_secret(String tw_access_secret) {
		this.tw_access_secret = tw_access_secret;
	}

	public boolean hasSecrets() {
		if (tw_access_secret != null && tw_access_token != null && !tw_access_secret.equals("") && !tw_access_token.equals("")) {
			return true;
		} else {
			return false;
		}
	}

	public void setSecurityLevel(Integer securityLevel) {
		this.securityLevel = securityLevel;
	}

	public Integer getSecurityLevel() {
		return securityLevel;
	}


}
